#!/bin/sh

if [ -z "$JAVA_HOME" ];
    then
        WS_BIN=wsimport
else
    WS_BIN="$JAVA_HOME/bin/wsimport"
fi

if [ "$1" == "--full" ];
    then
        mkdir bin
        mkdir src
        $WS_BIN https://sitenethomologa.serasa.com.br/MeProteja?wsdl -d bin -s src -keep
        jar cf meproteja-client-3.2.jar -C bin/ .
        jar cf meproteja-client-3.2-sources.jar -C src/ .
else
    if [ "$1" == "--jar" ];
        then
            jar cf meproteja-client-3.2.jar -C bin/ .
            jar cf meproteja-client-3.2-sources.jar -C src/ .
    else
        if [ ! -z "$1" ];
            then
                if [ "$1" != "--basic" ];
                    then
                        echo Uso:
                        echo "  $0 [--full|--jar|--basic]"
                        echo "    --full  Executa wsimport, jar e maven install"
                        echo "    --jar   Executa jar e maven install"
                        echo "    --basic Executa maven install (DEFAULT)"
                        exit 1
                else
                    if [ $# -gt 1 ];
                        then
                            echo Uso:
                            echo "  $0 [--full|--jar|--basic]"
                            echo "    --full  Executa wsimport, jar e maven install"
                            echo "    --jar   Executa jar e maven install"
                            echo "    --basic Executa maven install (DEFAULT)"
                            exit 2
                    fi
                fi
        fi
    fi
fi

mvn install:install-file -Dfile=meproteja-client-3.2.jar -Dsources=meproteja-client-3.2-sources.jar -DgroupId=br.com.serasaexperian -DartifactId=meproteja-client -Dversion=3.2 -Dpackaging=jar -DgeneratePom=true
